package entity;

public class HourlyEmployee extends Employee {
    private double hourlyRate; // 时薪
    private double workHours; // 月工作时长

    public HourlyEmployee(String name, String empId, double hourlyRate, double workHours) {
        super(name, empId);
        this.hourlyRate = hourlyRate;
        this.workHours = workHours;
    }

    @Override
    public double calculateSalary() throws Exception {
        if (workHours < 0 || workHours > 300) {
            throw new Exception("工作时长异常（0-300小时/月）");
        }
        return hourlyRate * workHours;
    }
}